home *** CD-ROM | disk | FTP | other *** search
- Path: news.nyu.edu!schonberg!dewar
- From: dewar@cs.nyu.edu (Robert Dewar)
- Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu
- Subject: Re: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada)
- Date: 9 Apr 1996 21:51:37 -0400
- Organization: Courant Institute of Mathematical Sciences
- Message-ID: <dewar.829101012@schonberg>
- References: <JSA.96Feb16135027@organon.com> <dewar.828936837@schonberg> <828964950snz@genesis.demon.co.uk> <dewar.828987544@schonberg> <4kbuebINNrho@keats.ugrad.cs.ubc.ca> <dewar.829048603@schonberg> <4kets3$ic0@news-s01.ny.us.ibm.net>
- NNTP-Posting-Host: schonberg.cs.nyu.edu
- X-Newsreader: NN version 6.5.0 (NOV)
-
- Mike notes/asks
-
- >I'm a latecomer to this dispute, but this is not smart:
- >
- > char buf[100];
- > read(fd,buf,1000);
- >
- >By the way, how did all this get started?
-
- Good question, I don't particularly see any dispute here. Obviously
- noone ever wrote code so obviously peculiar as your above example!
-
- The exact code, which appeared in the GNAT runtime was a loop to
- read a file that had in the loop
-
- read(fd,p,16*1024);
-
- to read the file in chunks of 16K. The last call exactly filled the
- remaining buffer which had been sized to exactly fit the size of the
- file.
-
- This code worked fine for a long time on nearly all systems, and in fact
- if you read the spec should work on most systems. But it failed on Linux
- (and was immediately corrected, no big deal!) and the reason is that
- Linux has subtly different semantics. The issue was whether any of the
- so-called specs for read (POSIX or SPEC1170) were clear enough to
- determine which of the two observed implementation models was "right".
-
- Turns out that no spec we could find (no one seems to have SPEC1170)
- precisely defined the specs.
-
- The wandering off into whether the code involved was or was not a good
- idea (obviously it was not!) is irrelevant. I was just using this as
- an example of a portability problem caused by weak specifications.
- Peter takes the odd view that it is not a portability problem because
- the code was not well defined, and therefore not portable. This seems
- a bit of a useless observation--Peter has determined that only
- portable code is portable, not terribly useful :-).
-
- Kazimir at first claimed that the spec clearly favored the Linux
- interpretation, then could not find any evidence and appealed to
- unwritten rules :-)
-
-
- But just to be clear, there is no dispute over whether the code as
- written was a good idea, it was simply an interesting example of
- a portability problem resulting from weak specs. The disussion
- showed to an extent that surprised even me that the specs for
- such routines are really horribly weak, at least in POSIX.
-
-